package com.bristua.barcode.common.util;

import com.google.gson.Gson;

import java.util.Map;

/**
 * Created by Administrator on 2017/9/22 0022.
 */
public class JsonUtil {
    private final static Gson gson = new Gson();

    public static String toJson(Object obj) {
        return gson.toJson(obj);
    }

    public static Map json2Map(String json) {
        return gson.fromJson(json, Map.class);
    }

    public static <T> T json2Object(String json, Class<T> cls) {
        Object o = gson.fromJson(json, cls);
        return gson.fromJson(json, cls);
    }
}
